package com.dferreira.languagesteach.activities;

import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.PreferenceActivity;

import com.dferreira.languagesteach.R;
import com.dferreira.languagesteach.constants.Constants;
import com.dferreira.languagesteach.utils.DataPaths;

public class PreferencesActivity extends PreferenceActivity {

    /**
     * @param savedInstanceState If the activity is being re-initialized after
     *                           previously being shut down then this Bundle contains the data it most
     *                           recently supplied in {@link #onSaveInstanceState}.  <b><i>Note: Otherwise it is null.</i></b>
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        CheckBoxPreference onSDcard;
        DataPaths dataPaths;
        String onSdcardKey;

        onSdcardKey = Constants.ON_SDCARD;

        super.onCreate(savedInstanceState);
        dataPaths = new DataPaths(this);
        //noinspection deprecation
        addPreferencesFromResource(R.xml.prefs);
        //noinspection deprecation
        onSDcard = (CheckBoxPreference) getPreferenceManager().findPreference(onSdcardKey);
        if (onSDcard != null) {
            onSDcard.setEnabled(dataPaths.sdCardIsAvailable());
        }
    }

}
